package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.ArchivedOrder;
import com.pgybook.db.entity.domain.ArchivedOrderEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface ArchivedOrderMapper {
    int countByExample(ArchivedOrderEx example);

    int deleteByExample(ArchivedOrderEx example);

    @Delete({
            "delete from archivedorder",
            "where BOOKINORDER = #{bookinorder,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long bookinorder);

    @Insert({
            "insert into archivedorder (ORDERID, CUSTID, ",
            "LIBID, IPADDRESS, ",
            "EXPCOMID, ID, EXPNO, ",
            "WEIGHT, POSTAGE, ",
            "STATUS, DELIVERADDRESS, ",
            "CONTACT, PHONE, ",
            "ZIPCODE, CRTTIME, ",
            "UPDTIME, DELIVERTIME)",
            "values (#{orderid,jdbcType=BIGINT}, #{custid,jdbcType=BIGINT}, ",
            "#{libid,jdbcType=INTEGER}, #{ipaddress,jdbcType=VARCHAR}, ",
            "#{expcomid,jdbcType=INTEGER}, #{id,jdbcType=INTEGER}, #{expno,jdbcType=VARCHAR}, ",
            "#{weight,jdbcType=INTEGER}, #{postage,jdbcType=DECIMAL}, ",
            "#{status,jdbcType=INTEGER}, #{deliveraddress,jdbcType=VARCHAR}, ",
            "#{contact,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
            "#{zipcode,jdbcType=VARCHAR}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{updtime,jdbcType=TIMESTAMP}, #{delivertime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "bookinorder", before = false, resultType = Long.class)
    int insert(ArchivedOrder record);

    int insertSelective(ArchivedOrder record);

    List<ArchivedOrder> selectByExample(ArchivedOrderEx example);

    @Select({
            "select",
            "BOOKINORDER, ORDERID, CUSTID, LIBID, IPADDRESS, EXPCOMID, ID, EXPNO, WEIGHT, ",
            "POSTAGE, STATUS, DELIVERADDRESS, CONTACT, PHONE, ZIPCODE, CRTTIME, UPDTIME, ",
            "DELIVERTIME",
            "from archivedorder",
            "where BOOKINORDER = #{bookinorder,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    ArchivedOrder selectByPrimaryKey(Long bookinorder);

    int updateByExampleSelective(@Param("record") ArchivedOrder record, @Param("example") ArchivedOrderEx example);

    int updateByExample(@Param("record") ArchivedOrder record, @Param("example") ArchivedOrderEx example);

    int updateByPrimaryKeySelective(ArchivedOrder record);

    @Update({
            "update archivedorder",
            "set ORDERID = #{orderid,jdbcType=BIGINT},",
            "CUSTID = #{custid,jdbcType=BIGINT},",
            "LIBID = #{libid,jdbcType=INTEGER},",
            "IPADDRESS = #{ipaddress,jdbcType=VARCHAR},",
            "EXPCOMID = #{expcomid,jdbcType=INTEGER},",
            "ID = #{id,jdbcType=INTEGER},",
            "EXPNO = #{expno,jdbcType=VARCHAR},",
            "WEIGHT = #{weight,jdbcType=INTEGER},",
            "POSTAGE = #{postage,jdbcType=DECIMAL},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "DELIVERADDRESS = #{deliveraddress,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "ZIPCODE = #{zipcode,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "DELIVERTIME = #{delivertime,jdbcType=TIMESTAMP}",
            "where BOOKINORDER = #{bookinorder,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(ArchivedOrder record);
}
